package com.carey.gae.data;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * @author Carey.RS.Zhou
 * 
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class OAuthProperties implements Serializable {

	private static final long serialVersionUID = -5928329965718874494L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	// user info
	@Persistent
	private String consumer_key;
	@Persistent
	private String consumer_secret;

	// url info
	@Persistent
	private String request_token_url;
	@Persistent
	private String authorize_token_url;
	@Persistent
	private String access_token_url;

	// method
	@Persistent
	private String oauth_signature_method;
	@Persistent
	private String http_method;

	// request token
	@Persistent
	private String request_token;
	@Persistent
	private String request_token_secret;

	// authorize token
	@Persistent
	private String authorize_token;
	@Persistent
	private String authorize_token_verifier;

	// access token
	@Persistent
	private String access_token;
	@Persistent
	private String access_token_secret;

	public String getConsumer_key() {
		return consumer_key;
	}

	public void setConsumer_key(String consumerKey) {
		consumer_key = consumerKey;
	}

	public String getConsumer_secret() {
		return consumer_secret;
	}

	public void setConsumer_secret(String consumerSecret) {
		consumer_secret = consumerSecret;
	}

	public String getRequest_token_url() {
		return request_token_url;
	}

	public void setRequest_token_url(String requestTokenUrl) {
		request_token_url = requestTokenUrl;
	}

	public String getAuthorize_token_url() {
		return authorize_token_url;
	}

	public void setAuthorize_token_url(String authorizeTokenUrl) {
		authorize_token_url = authorizeTokenUrl;
	}

	public String getAccess_token_url() {
		return access_token_url;
	}

	public void setAccess_token_url(String accessTokenUrl) {
		access_token_url = accessTokenUrl;
	}

	public String getOauth_signature_method() {
		return oauth_signature_method;
	}

	public void setOauth_signature_method(String oauthSignatureMethod) {
		oauth_signature_method = oauthSignatureMethod;
	}

	public String getHttp_method() {
		return http_method;
	}

	public void setHttp_method(String httpMethod) {
		http_method = httpMethod;
	}

	public String getRequest_token() {
		return request_token;
	}

	public void setRequest_token(String requestToken) {
		request_token = requestToken;
	}

	public String getRequest_token_secret() {
		return request_token_secret;
	}

	public void setRequest_token_secret(String requestTokenSecret) {
		request_token_secret = requestTokenSecret;
	}

	public String getAccess_token() {
		return access_token;
	}

	public void setAccess_token(String accessToken) {
		access_token = accessToken;
	}

	public String getAccess_token_secret() {
		return access_token_secret;
	}

	public void setAccess_token_secret(String accessTokenSecret) {
		access_token_secret = accessTokenSecret;
	}

	public String getAuthorize_token() {
		return authorize_token;
	}

	public void setAuthorize_token(String authorizeToken) {
		authorize_token = authorizeToken;
	}

	public String getAuthorize_token_verifier() {
		return authorize_token_verifier;
	}

	public void setAuthorize_token_verifier(String authorizeTokenVerifier) {
		authorize_token_verifier = authorizeTokenVerifier;
	}

	public void setCopy(OAuthProperties newOP) {

		// user info
		this.consumer_key = newOP.consumer_key;
		this.consumer_secret = newOP.consumer_secret;

		// url info
		this.request_token_url = newOP.request_token_url;
		this.authorize_token_url = newOP.authorize_token_url;
		this.access_token_url = newOP.access_token_url;

		// method
		this.oauth_signature_method = newOP.oauth_signature_method;
		this.http_method = newOP.http_method;

		// request token
		this.request_token = newOP.request_token;
		this.request_token_secret = newOP.request_token_secret;

		// authorize token
		this.authorize_token = newOP.authorize_token;
		this.authorize_token_verifier = newOP.authorize_token_verifier;

		// access token
		this.access_token = newOP.access_token;
		this.access_token_secret = newOP.access_token_secret;
	}

	@Override
	public boolean equals(Object arg0) {
		if (arg0 == null || !(arg0 instanceof OAuthProperties)) {
			return false;
		}

		OAuthProperties newOP = (OAuthProperties) arg0;

		boolean re = true;

		// user info
		re &= this.consumer_key == newOP.consumer_key;
		re &= this.consumer_secret == newOP.consumer_secret;

		// url info
		re &= this.request_token_url == newOP.request_token_url;
		re &= this.authorize_token_url == newOP.authorize_token_url;
		re &= this.access_token_url == newOP.access_token_url;

		// method
		re &= this.oauth_signature_method == newOP.oauth_signature_method;
		re &= this.http_method == newOP.http_method;

		// request token
		re &= this.request_token == newOP.request_token;
		re &= this.request_token_secret == newOP.request_token_secret;

		// authorize token
		re &= this.authorize_token == newOP.authorize_token;
		re &= this.authorize_token_verifier == newOP.authorize_token_verifier;

		// access token
		re &= this.access_token == newOP.access_token;
		re &= this.access_token_secret == newOP.access_token_secret;

		return re;
	}
}
